
package scalaSci

// define exponentation operator as ^^
// we require when both the base and the exponent are Ints to return Int
class expIntOperator(base: Int)  {
 def ^^ ( exponent: Int) = java.lang.Math.pow(base, exponent).asInstanceOf[Int]
 def ^^ ( exponent: Double) = java.lang.Math.pow(base, exponent)
}

class expDoubleOperator(base: Double)  {
 def ^^ ( exponent: Double) = java.lang.Math.pow(base, exponent)
}

// define implicit conversions for extended operators
object implicitConvOperators {
    implicit def doubleToExpInt(x: Double) = new expDoubleOperator(x)
    implicit def intToExpInt(x: Int) = new expIntOperator(x)
}